package com.wjyf.reducing_bento.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wjyf.reducing_bento.annotation.AuthCheck;
import com.wjyf.reducing_bento.common.BaseResponse;
import com.wjyf.reducing_bento.common.ResultUtils;
import com.wjyf.reducing_bento.model.vo.InviteRecordVo;
import com.wjyf.reducing_bento.model.vo.InviteRewardVo;
import com.wjyf.reducing_bento.service.InviteRecordService;
import com.wjyf.reducing_bento.service.InviteRewardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import static com.wjyf.reducing_bento.constant.UserConstant.ADMIN;

/**
 * @description:
 * @author：lrk
 * @date: 2023/4/30
 */
@RestController
@Api(tags = "邀请奖励")
@RequestMapping("invite-reward")
public class InviteRewardController {

    @Resource
    private InviteRewardService inviteRewardService;

    @GetMapping("user-invite-reward-list")
    @ApiOperation("用户获取自己的邀请奖励")
    private BaseResponse userGetInviteRewardList(
            @RequestParam @ApiParam("当前页码") Long current,
            @RequestParam @ApiParam("当页大小") Long pageSize,
            HttpServletRequest request
    ) {
        Page<InviteRewardVo> inviteRewardVoPage = inviteRewardService.userGetInviteRewardList(current, pageSize, request);
        return ResultUtils.success(inviteRewardVoPage);
    }

    @GetMapping("invite-reward-list")
    @ApiOperation("管理员获取邀请奖励")
    @AuthCheck(mustRole = ADMIN)
    private BaseResponse getInviteRewardList(
            @RequestParam @ApiParam("当前页码") Long current,
            @RequestParam @ApiParam("当页大小") Long pageSize
    ) {
        Page<InviteRewardVo> inviteRewardVoPage = inviteRewardService.adminGetInviteRewardList(current, pageSize);
        return ResultUtils.success(inviteRewardVoPage);
    }

}
